<?php
namespace App\Http\Controllers\Home;
use App\Models\Recharge;
use App\Models\Setting;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/9/4
 * Time: 11:54
 */
class ManageController extends BaseController{
     public function __construct(Recharge $recharge , Setting $setting)
     {
         parent::__construct();
         $this->recharge = $recharge; // 注入充值模型
         $this->setting  = $setting;
     }

     // 首页
     public function getIndex(){
          return view('home.recharge.index');
     }

     // eth 充值
     public function getEthView(){
           return view('home.recharge.ethpay');
     }

     // eth 充值
     public function postEthpay(){
           $res = $this->recharge->addRechagr(request());
           if($res['state']==200){
                 return redirect('/manage/reslut?pay=success');
           }else{
                 return redirect()->back()->with('message', $res['msg'])->withInput();
           }
     }

     // 充值结果
     public function getReslut(){
          $system = $this->setting->getSetting('system');
          return view('home.recharge.success',compact('res','system'));
     }

     // bth 充值
     public function postBthpay(){
          $res = $this->recharge->addRechagr(request());
          if($res['state']==200){
               return redirect('/manage/reslut?pay=success');
          }else{
               return redirect()->back()->with('message', $res['msg'])->withInput();
          }
     }

     // bth 充值
     public function getBthView(){
          return view('home.recharge.bthpay');
     }

     // 读取充值列表
     public function getRechageList(){
           $res = $this->recharge->rechargeList();
           return view('home.recharge.list',compact('res'));
     }
}